/**
 *
 *   █████▒█    ██  ▄████▄   ██ ▄█▀       ██████╗ ██╗   ██╗ ██████╗
 * ▓██   ▒ ██  ▓██▒▒██▀ ▀█   ██▄█▒        ██╔══██╗██║   ██║██╔════╝
 * ▒████ ░▓██  ▒██░▒▓█    ▄ ▓███▄░        ██████╔╝██║   ██║██║  ███╗
 * ░▓█▒  ░▓▓█  ░██░▒▓▓▄ ▄██▒▓██ █▄        ██╔══██╗██║   ██║██║   ██║
 * ░▒█░   ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄       ██████╔╝╚██████╔╝╚██████╔╝
 *  ▒ ░   ░▒▓▒ ▒ ▒ ░ ░▒ ▒  ░▒ ▒▒ ▓▒       ╚═════╝  ╚═════╝  ╚═════╝
 *  ░     ░░▒░ ░ ░   ░  ▒   ░ ░▒ ▒░
 *  ░ ░    ░░░ ░ ░ ░        ░ ░░ ░
 *           ░     ░ ░      ░  ░
 */

import React from 'react';

import {
    StackNavigator
} from 'react-navigation';

import PageMenu from './PageMenu';
import PageTabNavi from './PageTabNavi';
import PageStackNavi1 from './PageStackNavi1';
import PageStackNavi2 from './PageStackNavi2';
import PageListView from './PageListView';
import PageFlatList from './PageFlatList';
import PageSelectionList from './PageSelectionList';
import PageAnimate from './PageAnimate';
import PageLayoutAnimate from './PageLayoutAnimate';
import PagePanResponser from './PagePanResponser';
import PageListStackConfig from './PageListStackConfig';
import CardStackStyleInterpolator from "react-navigation/src/views/CardStack/CardStackStyleInterpolator";
import PageButton from "./PageButton";
import PageLineItem from "./PageLineItem";
import PageAlertItem from "./PageAlertItem";
import PageImage from "./PageImage";
import PageImageItem from "./PageImageItem";
import PageImageSource from "./PageImageSource";
import ProgressBar from "./PageProgressBar";
import AsyncStorageDemo from "./PageAsyncStorage";
import PageSdCardStorage from "./PageSdCardStorage";
import PageSwipList from "./PageSwipList";

import {Button,} from "react-native";
import PageDrawerNavi from "./PageDrawerNavi";
import * as Color from "../constant/Color";

import Global from './../../gaqu/Global';
import GaQuAppStartUp from '../../gaqu/view/sys/BizAppStartUp';
import GaQuLogin from '../../gaqu/view/sys/GaquLogin';
import RoleSelect from './../../gaqu/view/sys/RoleSelect';
import CabinList from '../../gaqu/view/sevice/CabinList';
import CabinOperateMain from "../../gaqu/view/sevice/CabinOperateMain";
import CabinExerciseList from "../../gaqu/view/sevice/CabinExerciseList";
import RippleButtonBorderless from "../widget/btn/RippleButtonBorderless";
import PersonExerciseList from "../../gaqu/view/sevice/PersonExerciseList";
import PersonCharge from "../../gaqu/view/sevice/PersonCharge";
import PersonMarkerManage from "../../gaqu/view/sevice/PersonMarkerManage";
import RefoundList from "../../gaqu/view/finance/RefoundList";
import CabinReportList from "../../gaqu/view/statistics/CabinReportList";
import CabinReport from "../../gaqu/view/statistics/CabinReport";

/** 这里的都是不用在菜单列表中显示的，但是都要被路由的页面 */
let mStacks = {

    /** 默认显示 */
    'Main': {
        screen: PageMenu,
        navigationOptions: {
            headerTitle: 'Main'
        }
    },

    'GaQuAppStartUp':{
        screen: GaQuAppStartUp,
        navigationOptions: {
            header: false, // 不显示导航栏
            headerTitle: '嘎趣跑跑'
        }
    },

    'CabinReport':{
        screen: CabinReport,
    },

    'CabinReportList':{
        screen: CabinReportList,
    },

    'RefoundList':{
        screen: RefoundList,
    },


    'PersonMarkerManage':{
        screen: PersonMarkerManage,
    },

    'PersonCharge':{
        screen: PersonCharge,
    },

    'PersonExerciseList':{
        screen: PersonExerciseList,
    },

    'CabinOperateMain':{
        screen: CabinOperateMain,
    },

    'CabinExerciseList':{
        screen: CabinExerciseList,
    },

    'CabinList':{
        screen: CabinList,
        navigationOptions: {
            headerTitle: '选择仓体'
        }
    },

    'RoleSelect':{
        screen: RoleSelect,
        navigationOptions: {
            header: false, // 不显示导航栏
            headerTitle: '选择角色'
        }
    },

    'GaQuLogin':{
        screen: GaQuLogin,
        navigationOptions: {
            headerTitle: '嘎趣跑跑'
        }
    },


    'tab': {
        screen: PageTabNavi,
        // screen: TopTab,
        navigationOptions: {
            headerTitle: 'Tab'
        }
    },

    'drawer': {
        screen: PageDrawerNavi,
        navigationOptions: {
            headerTitle: '侧拉'
        }
    },

    'stack': {
        screen: PageStackNavi1,
        navigationOptions: {
            headerTitle: 'Stack outer1'
        }
    },

    'Chat': {
        screen: PageStackNavi2,
    },

    'Listview': {
        screen: PageListView,
        navigationOptions: {
            headerTitle: 'ListView(不重用,已废弃)'
        }
    },

    'FlatList': {
        screen: PageFlatList,
        navigationOptions: {
            headerTitle: 'FlatList(重用,头尾,分割线,指定跳转,上拉)'
        }
    },

    'SelectionList': {
        screen: PageSelectionList,
        navigationOptions: {
            headerTitle: 'SelectionList(分组/吸顶,FlatList)'
        }
    },

    'SwipListView': {
        screen: PageSwipList,
        navigationOptions: {
            headerTitle: 'SwipListView(左右滑)'
        }
    },

    'PagePanResponser': {
        screen: PagePanResponser,
        navigationOptions: {
            headerTitle: 'PagePanResponser'
        }
    },

    'PageAnimate': {
        screen: PageAnimate,
        navigationOptions: {
            headerTitle: 'PageAnimate'
        }
    },

    'PageLayoutAnimate': {
        screen: PageLayoutAnimate,
        navigationOptions: {
            headerTitle: 'PageLayoutAnimate'
        }
    },

    'PageButton': {
        screen: PageButton,
        navigationOptions: {
            headerTitle: 'Button'
        }
    },

    'PageImage': {
        screen: PageImage,
        navigationOptions: {
            headerTitle: '图片样式'
        }
    },

    'PageImageSource': {
        screen: PageImageSource,
        navigationOptions: {
            headerTitle: '图片加载来源'
        }
    },

    'PageLineItem': {
        screen: PageLineItem,
        navigationOptions: {
            headerTitle: '各种行'
        }
    },

    'ProgressBar': {
        screen: ProgressBar,
        navigationOptions: {
            headerTitle: '各种进度条'
        }
    },

    'PageAlertItem': {
        screen: PageAlertItem,
        navigationOptions: {
            headerTitle: '各种弹窗'
        }
    },

    'PageImageItem': {
        screen: PageImageItem,
        navigationOptions: {
            headerTitle: '各种图片'
        }
    },

    'AsyncStorageDemo': {
        screen: AsyncStorageDemo,
        navigationOptions: {
            headerTitle: 'react-native-storage'
        }
    },

    'PageSdCardStorage': {
        screen: PageSdCardStorage,
        navigationOptions: {
            headerTitle: 'SD-storage'
        }
    },
};

/** 全项目所有路由页面 */
class StackManager {
    /** 真正首页列表的项 */
    static get() {
        /** 解构 */
        for (let pageBean of PageListStackConfig.getPages()) {
            let key:string = pageBean.key;
            let screen:Object = pageBean.screen;
            let headerTitle:string = pageBean.headerTitle;
            let navigationOptions:Object = pageBean.navigationOptions;

            if (!navigationOptions) {
                // 在遍历的同时给起设定属性名与属性值(可被枚举)
                Object.defineProperty(
                    mStacks,                                // 源对象
                    key,                                    // 属性名(PageBean.key)
                    {
                        enumerable: true,                   // 属性可枚举性
                        value: {                            // 属性值(为一种对象)
                            screen: screen,                 // 属性值(为一种对象)---> 属性值
                            navigationOptions: {            // 属性值(为一种对象)---> (属性值(为一种对象)---> 属性值)
                                headerTitle: headerTitle,
                            }
                        }
                    }
                );
            }
            else {
                // 在遍历的同时给起设定属性名与属性值(可被枚举)
                Object.defineProperty(
                    mStacks,                                        // 源对象
                    key,                                            // 属性名(PageBean.key)
                    {
                        enumerable: true,                           // 属性可枚举性
                        value: {                                    // 属性值(为一种对象)
                            screen: screen,                         // 属性值(为一种对象)---> 属性值
                            navigationOptions: navigationOptions,   // 属性值(为一种对象)---> (属性值(为一种对象)---> 属性值)
                        }
                    }
                );
            }
        }
        return mStacks;
    }
}

/** [这里优先级底, 通用配置]全项目所有路由页面的跳转配置,也可在[路由项的navigationOptions]属性里单独配置,且优先级更高 */
const NavigationOptions = {
    // initialRouteName: 'Home',
    // initialRouteParams: {initPara: '初始页面参数'},
    navigationOptions: {
        gesturesEnabled: true,
        // headerTitle: '标题',
        headerTintColor:Color.white,    // 整个头部的颜色
        // headerTitleStyle: {fontSize: 18, color: Color.white},    // 头部的标题style
        headerStyle: {height: 48, backgroundColor: Color.colorPrimary},
    },
    // paths: 'page/main',
    // mode: 'card',
    headerMode: 'screen',
    // cardStyle: {backgroundColor: "#ffffff"},
    transitionConfig: (() => ({
        screenInterpolator: CardStackStyleInterpolator.forHorizontal,
    })),
    // onTransitionStart: (() => {
    //     console.log('页面跳转动画开始');
    // }),
    // onTransitionEnd: (() => {
    //     console.log('页面跳转动画结束');
    // }),
};

/** 这里的数据会在首页的功能列表上面显示（只是全部stack的一部分） */
export default StackNavigator(StackManager.get(), NavigationOptions);

